﻿#region Header

/*
Behavioral Rating of Dancing Human Crowds based on Motion Patterns
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using paravili.Services;
using Sebarf.Services.Interfaces;

#endregion

namespace paravili.Steps {
	/// <summary>
	/// Writes the current frame number as a statistic value by the IStatisticValuesLocatorService
	/// </summary>
	public class FrameNumberVisualizer : ProcessStepWithMeasurement<Object> {
		#region Public Properties

		[ConfigurabelBooleanValue(Name = "is enable")]
		public bool IsEnable { get; set; }

		[ServiceRequest]
		public IStatisticValuesLocatorService StatisticValuesLocatorService { get; set; }

		public IResetHandlerService ResetHandlerService {
			get { return null; }
			set { value.Reset += OnReset; }
		}

		[ConfigurabelStringValue(Name = "name of the statisticvalue that the framenumber value goes to")]
		public string OutputStatisticValue { get; set; }

		#endregion

		#region Public Methods

		public FrameNumberVisualizer() {
			IsEnable = true;
			OutputStatisticValue = "FrameNumber";
		}

		#endregion

		#region Private Methods

		private void OnReset(object sender, EventArgs e) {
			m_frameNumber = 0;
		}

		protected override object OnProcess(object toProcess) {
			m_frameNumber++;
			if (IsEnable) {
				StatisticValuesProviderService.SetStatisticValue(OutputStatisticValue, m_frameNumber);
			}
			return toProcess;
		}

		#endregion

		#region Private Fields

		private int m_frameNumber;

		#endregion
	}
}